package com.xyy.ec.pop.api.kingdinggmp.utils;

import com.alibaba.fastjson.annotation.JSONField;

import java.lang.reflect.Field;
import java.util.StringJoiner;

public class ClassUtils {

    public static String getClassNameList(Class<?> clazz) {
        StringJoiner stringJoiner = new StringJoiner(",");
        try {
            Field[] declaredFields = clazz.getDeclaredFields();
            for (Field declaredField : declaredFields) {
                if (declaredField.isAnnotationPresent(JSONField.class)){
                    JSONField annotation = declaredField.getAnnotation(JSONField.class);
                    stringJoiner.add(annotation.name());
                }else {
                    stringJoiner.add(declaredField.getName());
                }

            }

        } catch (Exception e) {
            e.printStackTrace();
        }
     return stringJoiner.toString();
    }
}
